package com.bdqn.spark.chapter05.value

import org.apache.spark.{SparkConf, SparkContext}

object Spark04_RDD_Operator_Transform_test {
  def main(args: Array[String]): Unit = {

    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("operator-flatMap-test")
    val sc = new SparkContext(sparkConf)

    // 算子 - flatMap
    val rdd = sc.makeRDD(List(List(1, 2), 3, List(4, 5)))

    rdd.flatMap(
      data => {
        data match {
          case list: List[_] => list
          case num: Int => List(num)
        }
      }
    ).collect.foreach(println)

    sc.stop()
  }
}
